<template>
  <el-card class="content-card dynamic-card">
    <template #header>
      <div class="card-header">
        <span>最新动态</span>
      </div>
    </template>
    <div class="dynamic-list">
      <div class="dynamic-item" v-for="(item, index) in dynamicData" :key="index">
        <div class="dynamic-time">{{ item.time }}</div>
        <div class="dynamic-content">{{ item.content }}</div>
      </div>
      <div v-if="dynamicData.length === 0" class="no-data">暂无动态</div>
    </div>
  </el-card>
</template>

<script setup lang="ts">
  interface DynamicItem {
    id?: string | number
    time: string
    content: string
  }

  interface Props {
    dynamicData: DynamicItem[]
  }

  const props = defineProps<Props>()
</script>

<style scoped>
  /* 最新动态样式 */
  .content-card {
    /* 移除固定高度，让组件自适应内容 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: none;
  }

  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
  }

  .dynamic-card {
    margin-top: 16px;
  }

  .dynamic-list {
    /* 移除最小高度限制 */
  }

  .dynamic-item {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .dynamic-item:hover {
    background-color: #f8f9fa;
    padding-left: 4px;
  }

  .dynamic-item:last-child {
    border-bottom: none;
  }

  .dynamic-time {
    font-size: 12px;
    color: #999;
    margin-bottom: 2px;
  }

  .dynamic-content {
    font-size: 13px;
    color: #333;
    font-weight: 500;
  }

  .no-data {
    text-align: center;
    padding: 12px 0;
    color: #999;
    font-size: 13px;
  }

  /* 响应式设计 */
  @media (max-width: 768px) {
    .dynamic-list {
      /* 移除最小高度限制 */
    }

    .dynamic-item {
      padding: 10px 0;
    }

    .dynamic-time {
      font-size: 11px;
    }

    .dynamic-content {
      font-size: 12px;
    }
  }
</style>
